home *** CD-ROM | disk | FTP | other *** search
-
-
-
- diff(1) diff(1)
-
-
-
- NAME
- diff - differential file comparator
-
- SYNOPSIS
- diff [ -efbh ] file1 file2
-
- DESCRIPTION
- Diff tells what lines must be changed in two files to bring
- them into agreement. If file1 (file2) is -, the standard input
- is used. If file1 (file2) is a directory, then a file in that
- directory with the name file2 (file1) is used. The normal
- output consists of a series of commands; each command is
- followed by the lines it affects. The commands tell how to turn
- file1 into file2. Just as in ed, arguments to the commands are
- numbers; either a single number for num or a pair of numbers
- separated by a comma (no spaces) for range (see the commands,
- below). A range that refers to a single line appears as a
- single number. The lines from file1 are prepended with <; from
- file2, with >.
-
- The commands resemble ed commands:
-
- num a range Append the range of lines from file2 after
- line num in file1.
-
- range d num Delete the range of lines in file1. Num
- points to the line in file2 last compared
- before the d command was triggered.
-
- range1 c range2 Change. Replace range1 in file1 with range2
- in file2. In the output, both ranges of
- lines appear after this command, one range at
- a time, separated by a short line (___).
-
- The commands tell how to convert file1 into file2; however, by
- exchanging a for d and reading backward, you can tell how to
- convert file2 into file1.
-
- Diff may appear to refer to lines that aren't there, especially
- lines at the end of the file. It believes that trailing blank
- lines are as significant as text.
-
- Options are:
-
- -b Ignores trailing blanks (spaces and tabs) and compares
- other strings of blanks as equal.
-
- -e Produces a script of a, c, and d commands for the
- editor ed. If run through ed, they will turn file1
- into file2 (see "EXAMPLES").
-
- -f Produces a script in the same format that -e does, but
- in reverse order. The script would not be meaningful to
- ed, however.
-
- -h Causes diff to do a fast, half-hearted job. Ranges of
- nonidentical text are resolved with giant change
- commands rather than a series of more precise append,
- change, and delete commands. It works only when
- changed stretches are short and well separated, but
- does work on files of unlimited length. Options -e and
- -f cannot be used with -h.
-
- Except in rare circumstances, diff finds a smallest sufficient
- set of file differences.
-
-
- EXAMPLES
- $ diff file1 file2
-
- 9a10
- >file2
-
- The above example shows that the only difference between file1
- and file2 is line 10 of file2. The output from the diff
- command states that to make file1 the same as file2, line 10
- from file2 should be appended to file1 after line 9. The line
- that should be appended is shown on the second output line.
- The string "file2" should be inserted after line 9 of file1 to
- make file1 and file2 the same.
-
- $ diff -e file1 file2 > ed_script_file
- $ ( cat ed_script_file ; echo '1, $p' ) | ed - file1.new
-
- $
-
- The above example compares the two files, produces an ed script
- to turn file1 into file2, and displays the results on the
- screen. NOTE: The only commands that will be part of the
- script file are a, c, and d commands.
-
- FILES
- possible temporary file /tmp/d?????
- /usr/lib/diffh for -h
-
- SEE ALSO
- cmp(1), comm(1), diff3(1), diffmk(1), ed(1).
-
- DIAGNOSTICS
- Exit status is 0 for no differences, 1 for some differences, 2
- for trouble.
-
- BUGS
- Editing scripts produced under the -e or -f option are naive
- about creating lines consisting of a single period (.).
-
- WARNINGS
- Missing newline at end of file X
- indicates that the last line of file X did not have a
- new-line. If the lines are different, they will be
- flagged and output, although the output will seem to
- indicate they are the same.
-